package edu.cs.cs160.storytime;


import android.app.Activity;
import android.content.Intent;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnTouchListener;
import android.widget.LinearLayout;

public class StoryTimeLibraryNew extends Activity{
	/*
	//private GLSurfaceView myView;
	//private StoryRenderer myRenderer;
	
    // Called when the activity is first created. 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        //requestWindowFeature(Window.FEATURE_NO_TITLE);
        //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        //WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.library);
        StoryTime.library.selectBook(0);
        myView = new GLSurfaceView(this) {
        	@Override
        	public boolean onTouchEvent(MotionEvent event) {
        		if(event.getAction() == MotionEvent.ACTION_DOWN)
        		{
	        		if(event.getX() < getWidth() / 3)
	        		{
	        			myRenderer.goLeft();
	        		}
	        		else if(event.getX() > getWidth() * 2 / 3 )
	        		{
	        			myRenderer.goRight();
	        		}
	        		else
	        		{
	        			if(myRenderer.getGeorgeLocation() == StoryRenderer.CENTER)
	        			{
	        				Intent myIntent = new Intent(this.getContext(), StoryTimeBook.class);
	        				startActivityForResult(myIntent, StoryTime.LOAD_BOOK);
	        			}
	        		}
        		}
        		
        		return true;
        	}
        };
        myRenderer = new StoryRenderer(this);
        myView.setRenderer(myRenderer);
        LinearLayout layout = (LinearLayout) findViewById(R.id.screen);
        //layout.addView(myView, layout.getChildCount());
        layout.addView(myView, layout.getChildCount());
		
    }
    
    @Override
	protected void onResume() {
		super.onResume();
		myView.onResume();
	}
    
    @Override
	protected void onPause() {
		super.onPause();
		myView.onPause();
    }

    @Override
    protected void onDestroy() {
    	myView = null;
    	myRenderer = null;
    	
    	super.onDestroy();
    	setResult(StoryTime.LOAD_BOOK_ON_EXIT);
    	Log.i("ending","ending library");
    }	
*/
}
